package Test0102;

public class Library {
    String name;
    Book[] arr = new Book[3];
    int i = 0;

    public Library() {
    }

    public Library(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Library{" +
                "name='" + name + '\'' +
                '}';
    }
    public void add(Book book){
        arr[i] = book;
        i++;
    }
    public void printAll(){
        for (Book a:arr){
            System.out.println(a);
        }
    }
    public Book findBookByAuthor(String JohnDoe){
        Book bookByAuthor = null;
        for (Book b:arr){
            if (b.getAuthorname()==JohnDoe){
                bookByAuthor = b;
            }
        }
        return bookByAuthor;
    }
    public boolean findBorrowedBook() {
        for (Book book : arr) {
            if (book.isState()) {
                return true;
            }
        }
        return false;
    }

}